<template>
  <div id="app">
      <header class="head">
      <a class="back tl" href="javascript:history.back(-1)">
        <i class="el-icon-arrow-left"></i>
      </a>
      <a href="javascript:;" class="tc">
        <small class="font_18 co_f">修改晨检</small>
      </a>

      <a href="javascript:;" class="save">
        <button @click="submitForm()" type="primary">保存</button>
      </a>
    </header>
    <main>
      <div class="formcontent">
        <ul>
          <li>
            <span><em>*</em>晨检日期 </span>
            <div class="froms">
              <label>{{this.datatime|time}}</label>
             
            </div>
          </li>
          <li>
            <span><em>*</em>晨检结果</span>
            <div class="froms">
              <el-select v-model="value" placeholder="请选择">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </div>
          </li>
          <li>
            <span><em>*</em>姓名</span>
            <div class="froms">
              <label>{{this.enterprisePersonName}}</label>
            </div>
          </li>
        </ul>
      </div>
    </main>
  </div>
</template>

<script>
  import {MorningRecordUpdate} from '../../api/api';
  import {MorningRecordDetail} from '../../api/api';

  export default {
    data() {
      return {
        options: [{
        value: '√',
        label: '正常'
      }, {
        value: '△',
        label: '发热'
      }, {
        value: '⊙',
        label: '腹泻'
      }, {
        value: '﹟',
        label: '皮肤溃疡'
      }, {
        value: '※',
        label: '其他传染病'
      }, {
        value: '不在岗',
        label: '不在岗位'
      }],
        value:this.$route.query.value,
        datatime:this.$route.query.datatime,
        enterprisePersonName:this.$route.query.name,
        enterprisePersonUnid:this.$route.query.enterprisePersonunid,
        Unid:this.$route.query.unid,
        listData:[],
        show: false, //默认隐藏
      };
    },
    methods: {     
      //数据加载方法
     
      //修改方法
      submitForm: function() {
      //定义需要传给通讯的参数：string Data--实体MorningRecord的序列化值 string UserUnid--当前操作用户标识   stringify对象解析字符串 parse字符串解析对象
      let varQueryData = {
        Name:this.enterprisePersonName,
        Unid:this.enterprisePersonUnid,
        //Unid: JSON.parse(localStorage.getItem('auth')).enterpriseUnid,//规范unid
      }
      let data = {
        MorningRecordDate:this.datatime,
        MorningRecordContent:this.value,
        Unid:this.Unid,
        EnterprisePerson: varQueryData,
      }
      let dataoption = {
        params: {
          Data: JSON.stringify(data),
          UserUnid: JSON.parse(localStorage.getItem('auth')).UserUnid,
        }
      }
      //调取接口
      MorningRecordUpdate(dataoption).then((res) => {
        if (res.success === true) {
          this.$message.success('保存成功');
           this.$router.go(-1);
        } else {
          this.$message.error(res.msg);
        }
      }).catch(function() {
        this.$message.error('网络异常。');
      })

    },
    },
    created() {
      this.getData();
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">

</style>
